@echo off
echo Starting WVP GB28181 Video Platform with Java 8...

REM Java 8 优化的JVM参数
set JAVA_OPTS=-Xms256m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=256m
set JAVA_OPTS=%JAVA_OPTS% -XX:+UseParallelGC -XX:+UseParallelOldGC
set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCDetails -XX:+PrintGCTimeStamps
set JAVA_OPTS=%JAVA_OPTS% -Xloggc:./logs/gc.log
set JAVA_OPTS=%JAVA_OPTS% -XX:+HeapDumpOnOutOfMemoryError
set JAVA_OPTS=%JAVA_OPTS% -XX:HeapDumpPath=./logs/
set JAVA_OPTS=%JAVA_OPTS% -Djava.awt.headless=true
set JAVA_OPTS=%JAVA_OPTS% -Dfile.encoding=UTF-8
set JAVA_OPTS=%JAVA_OPTS% -Duser.timezone=Asia/Shanghai
set JAVA_OPTS=%JAVA_OPTS% -Djava.net.preferIPv4Stack=true

REM 检查Java版本
echo Checking Java version...
java -version
if %errorlevel% neq 0 (
    echo Error: Java not found. Please install Java 8.
    pause
    exit /b 1
)

REM 创建logs目录
if not exist logs mkdir logs

echo Starting with Java 8 optimized settings...
echo JVM Options: %JAVA_OPTS%

REM 清理之前的编译
echo Cleaning previous build...
mvn clean

REM 编译并启动
echo Compiling and starting application...
mvn spring-boot:run -Dspring-boot.run.jvmArguments="%JAVA_OPTS%" -Dspring.profiles.active=dev

pause
